home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Found / FWExcLib / Sources / FWPostEx.cpp < prev    next >
Encoding:
Text File  |  1994-04-21  |  1.8 KB  |  74 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWPostEx.cpp
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Creation Date:        3/28/94
  7. //
  8. //    Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef   FWPOSTEX_H
  13. #include "FWPostEx.h"
  14. #endif
  15.  
  16. #ifndef   FWPRIMEM_H
  17. #include "FWPriMem.h"
  18. #endif
  19.  
  20. #ifndef   FWPRIDEB_H
  21. #include "FWPriDeb.h"
  22. #endif
  23.  
  24. #ifndef FWEXCDEF_H
  25. #include "FWExcDef.h"
  26. #endif
  27.  
  28. #ifdef FW_BUILD_MAC
  29. #pragma segment BEL
  30. #endif
  31.  
  32. void FW_CPostedException::Initialize(FW_SPrivPostedExceptionGlobals& globals)
  33. {
  34.     globals.gMaxPostedSize = _FW_CExceptionRuntime::kDefaultExceptionBufferSize;
  35.  
  36.     globals.gPostedException = (_FW_CException*) 
  37.                                     ::FW_PrimitiveAllocateBlock(globals.gMaxPostedSize);
  38.     FW_PRIV_ASSERT(globals.gPostedException != 0);
  39.     
  40.     globals.gPending = 0;
  41.  
  42.     FW_PRIV_ASSERT(!globals.gInitialized);
  43.     globals.gInitialized = 1;
  44. }
  45.  
  46. void FW_CPostedException::Terminate()
  47. {
  48.     FW_SPrivPostedExceptionGlobals& globals = GetPostedExceptionGlobals();
  49.     FW_PRIV_ASSERT(globals.gInitialized);
  50.     ::FW_PrimitiveFreeBlock(globals.gPostedException);
  51.     globals.gInitialized = 0;
  52. }
  53.  
  54. void FW_CPostedException::PostException(const _FW_CException& exception)
  55. {
  56.     FW_SPrivPostedExceptionGlobals& globals = GetPostedExceptionGlobals();
  57.     FW_PRIV_ASSERT(globals.gInitialized);
  58.     if (!globals.gPending)
  59.     {
  60.         exception.Copy(globals.gPostedException, globals.gMaxPostedSize);
  61.         globals.gPending = 1;
  62.     }
  63. }
  64.  
  65. void FW_CPostedException::ThrowPostedException()
  66. {
  67.     FW_SPrivPostedExceptionGlobals& globals = GetPostedExceptionGlobals();
  68.     FW_PRIV_ASSERT(globals.gInitialized);
  69.     if (globals.gPending)
  70.     {
  71.         globals.gPending = 0;
  72.         FW_THROW(*globals.gPostedException);
  73.     }
  74. }